﻿@model SCMS.UI.Areas.Admin.Models.SystemUser.SystemUserModel
@using SCMS.CoreBusinessLogic.Settings
<div class="partialViewCard">
    <div class="partialViewCardHeader"><h3>SCMS User Details</h3></div>
    <br />
    <table width="98%" align="center" border="0" cellpadding="2" cellspacing="2" style=" border-bottom: 1px solid Grey;">
        <tr class="gridheader2">
            <td width="25%">Name</td>
            <td width="25%">Email Address</td>
            <td width="25%">Phone Number</td>
            <td width="25%">Photo</td>            
        </tr>
        <tr>
            <td>
                @Model.FirstName
                @Html.Raw("&nbsp;")
                @Model.OtherNames
            </td>
            <td>
                @Model.Email
            </td>
            <td>
                @Model.OfficialPhone
            </td>
            <td rowspan="6" align="center">
                <table align="center">
                    <tr>
                        <td>
                            @if (Model.PhotoLocation.IsNotNullOrWhiteSpace())
                            {                            
                                <img src="@Url.Content(Model.PhotoLocation)" width="150" alt="" />                            
                            }
                            else
                            { 
                                <img src="@Url.Content("~/Content/themes/copenhagen/images/noPhoto.jpg")" width="150" alt="No photo" />                            
                            }
                        </td>
                    </tr>
                    <tr>
                        <td>
                            @if (Model.PersonSignatureImageId != null)
                            {
                                <img src="@Url.Action("Photo", "Person", new { id = Model.PersonSignatureImageId, area = "" })" alt="" style="max-width: 150px;" />
                            }
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
        <tr class="gridheader2">
            <td>Designation</td>
            <td>Country Sub Office</td>
            <td>Role(s)</td>
        </tr>
        <tr>
            <td>
                @foreach (var desg in Model.AvailableDesignation)
                {
                    if (desg.Value == Model.SelectedDesignationId.ToString())
                    { 
                        @desg.Text
                        break;
                    }
                }
            
            </td>
            <td>
                @foreach (var office in Model.AvailableCountrySubOffices)
                {
                    if (office.Value == Model.SelectedCountrySubOfficeId.ToString())
                    { 
                        @office.Text
                        break;
                    }
                }
            </td>
            <td>
                @{
                    string roles = "";
                    foreach (var role in Model.AvailableRoles)
                    {
                        if (role.Selected)
                        {
                            if (roles.Length > 0)
                            {
                                roles += ", " + role.Text;
                            }
                            else
                            {
                                roles = role.Text;
                            }
                        }
                    }
                    @Html.Raw(roles)
                }
            </td>
        </tr>
        <tr class="gridheader2">
            <td>Finance Limit</td>
            <td>Available</td>
            <td>Account Status</td>
        </tr>
        <tr>
            <td>
                @if (Model.FinanceLimitId != null)
                {
                    foreach (var financeLimit in Model.FinanceLimits)
                    {
                        if (financeLimit.Value == Model.FinanceLimitId.ToString())
                        { 
                            @financeLimit.Text
                            break;
                        }
                    }
                }
                else
                { 
                    @Html.Raw("NOT SET")
                }
            </td>
            <td>
                @if (Model.Available)
                { 
                    @Html.Raw("YES")
                }
                else
                { 
                    @Html.Raw("NO")
                }
            </td>
            <td>
                @if (Model.Active)
                { 
                    @Html.Raw("Active, ")
                }
                else
                { 
                    @Html.Raw("Disabled, ")
                }
                @if (Model.Locked)
                { 
                    @Html.Raw("Locked")
                }
                else
                { 
                    @Html.Raw("Unlocked")
                }
            </td>
        </tr>
        <tr>
            <td colspan="3" valign="top">
                <table cellpadding="0" cellspacing="0">
                    <tr>
                        <td>
                            @if (Model.Id.IsNotEmpty())
                            {
                                <table>
                                    <tr>
                                        <td><b>Last Ip Address:</b></td>
                                        <td>@Html.DisplayFor(model => model.LastIpAddress)</td>
                                    </tr>
                                    <tr>
                                        <td><b>Last Login Date:</b></td>
                                        <td>@Model.LastLoginDate.FormatLongDatePatternWithTime()</td>
                                    </tr>
                                    <tr>
                                        <td><b>Failed Login Attempts:</b></td>
                                        <td>@Html.DisplayFor(model => model.UserLoginCount)</td>
                                    </tr>
                                    <tr>
                                        <td><b>Date Created:</b></td>
                                        <td>@Model.Created.FormatLongDatePatternWithTime()</td>
                                    </tr>
                                    <tr>
                                        <td><b>Last Modified:</b></td>
                                        <td>@Model.Modified.FormatLongDatePatternWithTime()</td>
                                    </tr>
                                    <tr>
                                        <td>
                                            @Ajax.ActionLink("Back to List", "List", new { id = "Edit" }, new AjaxOptions
                                       {
                                           UpdateTargetId = "AdminSystemUserDiv",
                                           LoadingElementId = "loading",
                                           Url = Url.Action("List"),
                                           OnSuccess = "initSorter();sorter.size(10);"
                                       })
                                        </td>
                                        <td></td>
                                    </tr>
                                </table>
                            }
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
    </table>
    <br />
</div>
